#include "MediaStateWaitingForMediaConnection.h"
#include "MediaStateMap.h"
#include "Trace.h"

namespace tsc
{
namespace mgw
{

using namespace tsc::common;

/*******************************************************************************
 *
 * Constructor
 *
 ******************************************************************************/
MediaStateWaitingForMediaConnection::MediaStateWaitingForMediaConnection() :
	MediaStateBase("WaitForMediaConn")
{

} // MediaStateWaitingForMediaConnection::MediaStateWaitingForMediaConnection

/*******************************************************************************
 *
 * Destructor
 *
 ******************************************************************************/
MediaStateWaitingForMediaConnection::~MediaStateWaitingForMediaConnection()
{

} // MediaStateWaitingForMediaConnection::~MediaStateWaitingForMediaConnection

//===================================================================
MediaStateWaitingForMediaConnection* MediaStateWaitingForMediaConnection::instance()
{
	static MediaStateWaitingForMediaConnection mInstance;
	return &mInstance;
}

//===================================================================
void
MediaStateWaitingForMediaConnection::handleEventSetupConnection(
    MediaGenerator* gen,
    MediaEventSetupConnection* event,
    EventData*& eventData)
{
    TRACE(3, "Handling event MediaEventSetupConnection");

    gen->setGeneratorId(event->getConnectionId());

    // TODO setup the socket
    TRACE_ERROR("NOT implemented yet");
    // TODO set the port on which the socket is listening
    gen->setServerMediaPort(0);

    EventData::deleteEvent(eventData);
}

} // namespace mgw
} // namespace tsc
